<extend name="Index:base" />
<block name="title"><title>运营</title></block>
<block name="style">
 <style>
.main,.panel-default>.panel-heading{
background:none;
}
body{
background:none;
}
.panel.panel-default,.panel .panel-body,.panel .panel-heading,.table-bordered {
	border:none;
}
.table-bordered > thead > tr > th, .table-bordered > tbody > tr > th, .table-bordered > tfoot > tr > th, .table-bordered > thead > tr > td, .table-bordered > tbody > tr > td, .table-bordered > tfoot > tr > td {
	border:none;		
	padding:15px;	
	line-height:8px;
	height: 8px;
	border-top: 1px solid #d4d4d4;
	border-bottom: 1px solid #d4d4d4;
}
.name strong{
color:#000000;
font-size:15px;
font-weight:600;
}
.name {
	color:#20a8d8;
	font-size:12px;
}
.smallfont {
	color:#9c9c9c;
	font-size:12px;
}

.align-center{
	text-align:center; 
}
.title2{
text-align:center;
}
.table-bordered > tbody > tr .wd{
	text-align:left;	
}

.col-xs-2,.col-xs-4{
padding-right:0;
margin:10px 0;
}
.col-sm-3{
width:10%;
}
.col-sm-2{
width:8%;
}
.col-sm-1{
width:5%;
}
.col-sm-4{
width:18%;
}
.col-sm-1,.col-sm-2{
margin:16px 0;
}
.col-sm-3,.col-sm-4{
margin:10px 0;
}
.col-sm-1,.col-sm-2,.col-sm-3,.col-sm-4{
padding-right:0;
}
 </style>
</block>
	<!-- start: Header -->
<block name="body">

			<!-- end: Main Menu -->
						
		<!-- start: Content -->
		<div class="main ">
		
			<div class="row">
				<div class="col-lg-12">
					<h3 class="page-header"><i class="fa fa-life-bouy"></i>限时折扣</h3>
				</div>
			</div>

			<div class="row">		
				<div class="col-lg-12">
					<div class="panel panel-default">
						<div class="panel-heading">
							<a class="btn btn-default" href="{:U('Operate/index')}" id="add_right"></i>活动管理</a>

							&nbsp;&nbsp;&nbsp;
							<a class="btn btn-default" href="{:U('Operate/index')}?type=add" id="add_right">添加活动</i></a>
							&nbsp;&nbsp;&nbsp;
													
							<h2><span class="break"></span><strong>申请参加活动店铺</strong></h2>					
						</div>&nbsp;&nbsp;&nbsp;
						<ol class="breadcrumb" style="height:70px;background-color: #ffffff;">							
							<li><i class="fa fa-warning"></i><a href="#">操作提示：</a></li><br/>	
							<li><font style="font-size:8px;color:#888;">1、点击添加活动按钮可以添加限时折扣活动，点击管理按钮可以对限时折扣活动内的商品进行管理<br/>
							2、点击删除按钮可以删除限时折扣活动</font></li>							
						</ol>
						<div class="panel-body">

							<table class="table table-striped table-bordered bootstrap-datatable datatable">
							  <thead>
								  <tr>

                                      <th class="title2">参加活动名称</th>
									   <th class="title2">活动状态</th>
									  <th class="title2">申请店铺</th>
									  <th class="title2">申请时间</th>	 
									  <th class="title2">审核状态</th>
									  <th class="title2">操作</th>
								  </tr>
							  </thead>   
							  <tbody id="state">
								<foreach name="list" item="vo">
								<tr>
									<td class="align-center">
										{$vo.xianshi_name}
									</td>
									 
									<td class="align-center">
									 <in name="vo.state" value="0"> 
									  <font style="color:red;">管理员关闭</font>
									  </in>
									  <in name="vo.state" value="1"> 
									  正常
									  </in>								
									</td>
									<td class="align-center">{$vo.st_name}</td>
									
									<td class="align-center">
									<if condition="$vo.lower_limit eq '0'" > 
									  不限
									  <else/>
									  {$vo.lower_limit}
									  </if>				
									</td>
									<td class="align-center">
									 <in name="vo.p_state" value="0"> 
									  <font style="color:#2196f3;">审核中</font>
									  </in>
									  <in name="vo.p_state" value="1"> 
									   <font style="color:green;">通过</font>
									  </in>
									  <in name="vo.p_state" value="2"> 
									  <font style="color:red;">未通过</font>
									  </in>
									  <in name="vo.p_state" value="3"> 
									  <font style="color:red;">被管理员踢出</font>
									  </in>
									</td>
									<td class="align-center">
										<a class="label label-primary"  href="/shop/show_store.html?stid={$vo.st_id}" target="_blank">查看店铺
										</a>

										<a href="javascript:;" data-id="{$vo.p_id}" data-type="edit">			
										&nbsp;
										<if condition="$vo.p_state neq '1'">
										<span class="label label-success" data-status="1" >通过</span>
										</if>
										<if condition="$vo.p_state eq '1'">
										<span class="label label-warning" data-status="3" >踢出活动</span>
										</if>
										</a>
										
										<if condition="$vo.p_state neq '1'" >
										<a  href="javascript:;" data-id="{$vo.p_id}" data-type="edit"><span class="label label-warning" data-status="2" >不通过</span>
										</a>
										</if>
									    <in name="vo.p_state" value="1"> 
										&nbsp;&nbsp;
										<a href="#" data-id="{$vo.p_id}" ><span class="label label-success" >产品</span>
										</a>
									    </in>
	
										<a href="#" data-id="{$vo.p_id}" data-type="del">					
										&nbsp;&nbsp;<span class="label label-danger">删除</span>
										</a>										
									 </td>

								</tr>
								</foreach>
							  </tbody>
						  </table>  
							<ul class="pagination">
								{$page}
							 </ul>						  
						</div>
					</div>
				</div><!--/col-->
			
			</div><!--/row-->				
			
		<!-- end: Content -->
		<br><br><br>
		
	</div><!--/container-->
		
</block>
<block name="script">
<script>


$("#state tr td a").click(function(){

    var id = $(this).attr('data-id');
	var state = $(this).find('span').attr('data-status');
	
	var type = $(this).attr('data-type');
	var username = $(this).attr('data-username');
	var mobile = $(this).attr('data-mobile');
	var realname = $(this).attr('data-realname');

	if (type=='del') {
		if(confirm("确定要删除吗？")){
			$.ajax({
				url:"{:U('Store/del')}",
				data:{id:id,table:8,str:'p_id'},
				type:'post',
				dataType:'json',
				success:function (e) {			
				//alert(id);
					alert(e.info); 
					location.reload();				
				}
			});	
		}else{
			//否
			return false;
		}
	}
	if (id && type=='edit') {
		if(confirm("确定要操作吗？")){

			if (state==3) {
				//alert(11);
				$.ajax({
					url:"{:U('Store/del')}",
					data:{id:id,table:9,str:'p_id'},
					type:'post',
					dataType:'json',
					success:function (e) {						
					}
				});
			}
			
			$.ajax({
				url:"{:U('Store/edit')}",
				data:{id:id,table:8,state:state,str:'p_id'},
				type:'post',
				dataType:'json',
				success:function (e) {			
				
					if (e.info==1) {
						alert('审核成功');
						location.reload();
					}else if (e.info==2) {
						alert('操作成功');
						location.reload();
					}else if (e.info==3) {
						alert('操作成功');
						location.reload();
					}else if(e.info==4){
						alert('操作失败');
					} 				
				}
			});		
		}else{
			//否
			return false;
		}	
	}   

});
</script>
</block>	









